package com.legal.app.service.impl;

import java.util.List;
import com.legal.app.domain.vo.LawyerHomeVO;
import com.legal.app.domain.vo.LawyerVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.legal.app.mapper.LawyerMapper;
import com.legal.app.domain.Lawyer;
import com.legal.app.service.ILawyerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.legal.common.core.domain.AjaxResult;
import com.legal.common.core.domain.TableDataInfo;
/**
 * 律师Service业务层处理
 * 
 * @author ALe
 * @date 2025-05-30
 */
@Service
public class LawyerServiceImpl extends ServiceImpl<LawyerMapper, Lawyer> implements ILawyerService
{
    @Autowired
    private LawyerMapper lawyerMapper;

    /**
     * 查询律师
     * 
     * @param id 律师主键
     * @return 律师
     */
    @Override
    public Lawyer selectLawyerById(Long id)
    {
        return lawyerMapper.selectLawyerById(id);
    }

    /**
     * 查询律师列表
     * 
     * @param lawyer 律师
     * @return 律师
     */
    @Override
    public List<Lawyer> selectLawyerList(Lawyer lawyer)
    {
        return lawyerMapper.selectLawyerList(lawyer);
    }

    /**
     * 新增律师
     * 
     * @param lawyer 律师
     * @return 结果
     */
    @Override
    public int insertLawyer(Lawyer lawyer)
    {
        return lawyerMapper.insertLawyer(lawyer);
    }

    /**
     * 修改律师
     * 
     * @param lawyer 律师
     * @return 结果
     */
    @Override
    public int updateLawyer(Lawyer lawyer)
    {
        return lawyerMapper.updateLawyer(lawyer);
    }

    /**
     * 批量删除律师
     * 
     * @param ids 需要删除的律师主键
     * @return 结果
     */
    @Override
    public int deleteLawyerByIds(Long[] ids)
    {
        return lawyerMapper.deleteLawyerByIds(ids);
    }

    /**
     * 删除律师信息
     * 
     * @param id 律师主键
     * @return 结果
     */
    @Override
    public int deleteLawyerById(Long id)
    {
        return lawyerMapper.deleteLawyerById(id);
    }

    /**
     * 查询首页律师列表
     *
     * @param pageSize 每页记录数
     * @param pageNum  当前页码
     * @return 律师列表
     */
    @Override
    public AjaxResult getHomeLawyers(Integer pageSize, Integer pageNum) {
        // 调用Mapper查询首页律师VO列表
        List<LawyerHomeVO> lawyerVOs = baseMapper.selectHomeLawyerList(pageSize, pageNum);

        // 查询总记录数
        int total = baseMapper.countOnlineLawyers();

        // 封装结果
        TableDataInfo tableData = new TableDataInfo();
        tableData.setCode(200);
        tableData.setMsg("查询成功");
        tableData.setRows(lawyerVOs);
        tableData.setTotal(total);

        return AjaxResult.success(tableData);
    }

    @Override
    public AjaxResult queryLawyersByCondition(LawyerHomeVO vo) {
        List<LawyerHomeVO> lawyerList = baseMapper.selectLawyerByCondition(vo);
        return AjaxResult.success(lawyerList);
    }

    @Override
    public LawyerVO getLawyerDetail(Long lawyerId) {
        return lawyerMapper.selectLawyerDetailById(lawyerId);
    }
}
